package de.mmis.core.pojop.request;

import de.mmis.core.base.abstracttree.Tree;

public class AbstractRequest implements Request {

	public enum RequestType {
		MethodCall, Observe, Deobserve, Help, Quit, Properties, Type, Interfaces, Echo, Error, JarData, ListMethods,
	}

	private final RequestType type;
	private final Tree data;

	// only used with error type
	private final Exception exception;

	public AbstractRequest(Exception exception) {
		this(RequestType.Error, null, exception);
	}

	public AbstractRequest(RequestType type, Tree data) {
		this(type, data, null);
	}

	private AbstractRequest(RequestType type, Tree data, Exception exception) {
		this.type = type;
		this.data = data;
		this.exception = exception;
	}

	public RequestType getType() {
		return this.type;
	}

	public Tree getData() {
		return this.data;
	}

	public Exception getException() {
		return this.exception;
	}
}
